import request from '@/utils/request'

const couponApi = {
  // 获取优惠券统计数据
  getStatisticData: (params) => {
    return request({
      url: '/promotion/coupon/chain/overview',
      method: 'GET',
      params
    })
  },
  // 优惠券列表
  getCouponList: (params) => {
    return request({
      url: '/promotion/coupon/chain/page',
      method: 'GET',
      params
    })
  },
  // 获取优惠券详情
  getCouponDetail: (couponId) => {
    return request({
      url: `/promotion/coupon/chain/get?id=${couponId}`,
      method: 'GET'
    })
  },
  // 新增优惠券
  addCoupon: (userType, data) => {
		return request({
			url: `/promotion/coupon/${userType == 1 ? 'chain' : 'supplier'}/create`,
			method: 'POST',
      data
		})
	},
  // 更新优惠券
  updateCoupon: (userType, data) => {
		return request({
      url: `/promotion/coupon/${userType == 1 ? 'chain' : 'supplier'}/update`,
			method: 'PUT',
      data
		})
	},
  // 删除优惠券
  deleteCoupon: (id) => {
		return request({
			url: `/promotion/coupon/chain/delete?id=${id}`,
      method: 'DELETE'
		})
	},
  // 发布优惠券
  updateCouponStatus: (data) => {
		return request({
			url: '/promotion/coupon/chain/update/status',
			method: 'PUT',
      data
		})
	},
  // 可选供应商列表
  getCheckSupplierList: (params) => {
		return request({
			url: '/vms/supplier/page',
			method: 'GET',
      params
		})
	},
  // 已选供应商列表
  getCheckedSupplierList: (ids) => {
		return request({
			url: `/vms/supplier/list?ids=${ids}`,
			method: 'GET'
		})
	},
  // 可选商品列表
  getCheckGoodsList: (params) => {
		return request({
			url: '/product/spu/page',
			method: 'GET',
      params
		})
	},
  // 已选商品列表
  getCheckedGoodsList: (ids) => {
		return request({
      url: `/product/spu/list/by/ids?ids=${ids}`,
      method: 'GET'
		})
	},
  // 优惠劵发放数据
  getCouponGrantData: (params) => {
		return request({
      url: '/promotion/coupon/chain/grant/data',
      method: 'GET',
      params
		})
	},
}

export default couponApi